﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dycox.Workflows.Conditions
{
    public class UserSelectedCondition : TransitionCondition
    {

        public UserSelectedCondition(Dictionary<string, string> parameters)
        {
            parameters.TryGetValue("label", out _label);
            parameters.TryGetValue("prompt", out _prompt);

        }

        private string _label;

        public string Label
        {
            get
            {
                if (_label != null) return _label;

                var target = this.Transition;
                if (target != null)
                    return target.TargetStage.DisplayName;

                return null;
            }
        }

        private string _prompt;

        public string Prompt
        {
            get { return _prompt; }
        }

        internal protected override bool Test(ConditionTestArguments args)
        {
            var contract = args.UseState;

            if (contract != null)
                return contract.UserAction == Transition.TargetStage.Name;
            else
                return false;
        }

        protected internal override void PopulateDependentProperties(List<string> list)
        {
        }
    }
}
